package com.tianhui.consignortwofei.pattern.orderStatus.status.impl;

import com.tianhui.consignortwofei.constant.OrderType;
import com.tianhui.consignortwofei.mvp.model.enty.OrderCondition;
import com.tianhui.consignortwofei.mvp.model.enty.OrderInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailItemInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailLineInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailOperateInfo;
import com.tianhui.consignortwofei.pattern.freightCalculation.CalculationController;
import com.tianhui.consignortwofei.pattern.orderStatus.status.IOrderStatus;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.Observable;

/**
 * @author fgs
 * @date 2020/8/27
 * @description 调度单功能中的订单详情
 **/
public class HeDanDetailStatus implements IOrderStatus {
    @Override
    public Observable getOrderListObservable(OrderCondition orderCondition) {
//        Map<String, String> map = new HashMap<>();
//        map.put("limit", "10");
//        map.put("offset", "1");
//        map.put("order", "desc");
//        map.put("sort", "sendordertime");
//        map.put("page", orderCondition.page + "");
//        return Api.getApiService().dispatchList(map);
        return null;
    }

    @Override
    public Observable getOrderDetailObservable(OrderCondition orderCondition) {
        Map<String, String> map = new HashMap<>();
//        map.put("limit", "10");
//        map.put("offset", "1");
//        map.put("order", "desc");
//        map.put("sort", "sendordertime");
//        map.put("page", orderCondition.page + "");
        map.put("dispatchno", orderCondition.dispatchNo);
//        return CommonConfig.getInstance().create(OrderApiService.class).getHeDanList(map);
        return null;
    }

    @Override
    public List getOrderDetailList(OrderInfo orderInfo) {
        List list = new ArrayList<>();

        DetailInfo detailInfo;
        DetailItemInfo detailItemInfo;
        DetailOperateInfo operateInfo;
        DetailLineInfo lineInfo;

        lineInfo = new DetailLineInfo();
        list.add(lineInfo);

        detailInfo = new DetailInfo();

        detailInfo.title = "司机信息";
        detailInfo.isShowTitleTip = true;
        detailInfo.infoList = new ArrayList<>();
        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "姓名：";
        detailItemInfo.content = orderInfo.drivername + " >>";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "车牌号：";
        detailItemInfo.content = orderInfo.vehiclenum;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "联系方式：";
        detailItemInfo.content = orderInfo.drivertel;
        detailInfo.infoList.add(detailItemInfo);

        list.add(detailInfo);

        lineInfo = new DetailLineInfo();
        list.add(lineInfo);

        detailInfo = new DetailInfo();
        detailInfo.title = "线路信息";
        detailInfo.isShowTitleTip = true;
        detailInfo.infoList = new ArrayList<>();

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "取单地：";
        detailItemInfo.content = orderInfo.placeprovince + orderInfo.placecity + orderInfo.placecounty + orderInfo.placedetails;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "装货地：";
        detailItemInfo.content = orderInfo.deliverprovince + orderInfo.delivercity + orderInfo.delivercounty + orderInfo.deliverdetails;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "目的地：";
        detailItemInfo.content = orderInfo.destinationprovince + orderInfo.destinationcity + orderInfo.destinationcounty + orderInfo.destinationdetails;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "取单人姓名：";
        detailItemInfo.content = orderInfo.placeusername;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "取单人电话：";
        detailItemInfo.content = orderInfo.placetel;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "装货人姓名：";
        detailItemInfo.content = orderInfo.deliverusername;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "装货人电话：";
        detailItemInfo.content = orderInfo.delivertel;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "收货人姓名：";
        detailItemInfo.content = orderInfo.destinationusername;
        detailInfo.infoList.add(detailItemInfo);


        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "收货人电话：";
        detailItemInfo.content = orderInfo.destinationtel;
        detailInfo.infoList.add(detailItemInfo);

        list.add(detailInfo);

        lineInfo = new DetailLineInfo();
        list.add(lineInfo);

        detailInfo = new DetailInfo();
        detailInfo.title = "货源信息";
        detailInfo.spanCount = 2;
        detailInfo.isShowTitleTip = true;
        detailInfo.infoList = new ArrayList<>();

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "货物类型：";
        detailItemInfo.content = orderInfo.goodstypetext;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "";
        detailItemInfo.content = "";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "货物描述：";
        detailItemInfo.content = orderInfo.goodsdescription;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "";
        detailItemInfo.content = "";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "重量：";
        detailItemInfo.content = orderInfo.weight + "吨";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "数量：";
        detailItemInfo.content = orderInfo.quantity + "件";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "运费单价：";
        detailItemInfo.content = orderInfo.baseprice + "元";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "运费单价（含税）：" + orderInfo.tradtaxprice + "元";
//        detailItemInfo.content = orderInfo.tradtaxprice + "元";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "运费总价：";
        detailItemInfo.content = orderInfo.totalprice + "元";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "运费总价（含税）：" + orderInfo.totaltradtaxprice + "元";
//        detailItemInfo.content = orderInfo.totaltradtaxprice + "元";
        detailInfo.infoList.add(detailItemInfo);

        list.add(detailInfo);


        lineInfo = new DetailLineInfo();
        list.add(lineInfo);

        detailInfo = new DetailInfo();
        detailInfo.title = "单据信息";
        detailInfo.isShowTitleTip = true;
        detailInfo.infoList = new ArrayList<>();

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "发送距离：";
        detailItemInfo.content = orderInfo.senddistance + "（km）";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "预计里程：";
        detailItemInfo.content = 0 + "（km）";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "单据有效时间：";
        detailItemInfo.content = orderInfo.ordertruetime;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "装货截止时间：";
        detailItemInfo.content = orderInfo.lendtime;
        detailInfo.infoList.add(detailItemInfo);

        list.add(detailInfo);


        lineInfo = new DetailLineInfo();
        list.add(lineInfo);

        detailInfo = new DetailInfo();
        detailInfo.title = "结算信息";
        detailInfo.isShowTitleTip = true;
        detailInfo.infoList = new ArrayList<>();

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "货物单价：";
        detailItemInfo.content = orderInfo.goodsunitprice + "元/吨";
        detailInfo.infoList.add(detailItemInfo);

        list.add(detailInfo);


        lineInfo = new DetailLineInfo();
        list.add(lineInfo);

        detailInfo = new DetailInfo();
        detailInfo.title = "账务信息";
        detailInfo.isShowTitleTip = true;
        detailInfo.spanCount = 2;
        detailInfo.infoList = new ArrayList<>();

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "成交重量：";
        detailItemInfo.content = orderInfo.tradweight + "吨";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "装车重量：";
        detailItemInfo.content = orderInfo.tranweight + "吨";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "收货重量：";
        detailItemInfo.content = orderInfo.recelveweight + "吨";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "结算重量：";
        detailItemInfo.content = orderInfo.settleweight + "吨";
        detailInfo.infoList.add(detailItemInfo);


        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "亏吨重量：";
//        detailItemInfo.content = orderInfo.loseweight + "吨";
        detailItemInfo.content = CalculationController.getInstance().getLoseWeight(orderInfo) + "吨";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "";
        detailItemInfo.content = "";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "运费单价：";
        detailItemInfo.content = orderInfo.baseprice + "元";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "补助金：";
        detailItemInfo.content = orderInfo.grants + "元";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "扣除费用：";
        detailItemInfo.content = orderInfo.otherpirce + "元";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "货物单价：";
        detailItemInfo.content = orderInfo.goodsunitprice + "元/吨";
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "亏吨扣除：";
        detailItemInfo.content = orderInfo.deductpirce + "元";
        detailInfo.infoList.add(detailItemInfo);

        list.add(detailInfo);

        lineInfo = new DetailLineInfo();
        list.add(lineInfo);

        detailInfo = new DetailInfo();
        detailInfo.title = "其他信息";
        detailInfo.isShowTitleTip = true;
        detailInfo.infoList = new ArrayList<>();

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "业务单号：";
        detailItemInfo.content = orderInfo.businessno;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "合同单号：";
        detailItemInfo.content = orderInfo.contractno;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "委托人：";
        detailItemInfo.content = orderInfo.clientperson;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "联系电话：";
        detailItemInfo.content = orderInfo.clienttel;
        detailInfo.infoList.add(detailItemInfo);

        list.add(detailInfo);

        operateInfo = new DetailOperateInfo();
        operateInfo.operate = orderInfo.isdelegateshipment;
        operateInfo.type = 2;
        list.add(operateInfo);

        return list;
    }


    @Override
    public int getOrderStatusType() {
        return OrderType.TYPE_DISPATCH;
    }

    @Override
    public String getOrderStatus(OrderInfo orderInfo) {
        return "状态：" + orderInfo.isstatetext;
    }

    @Override
    public String getDispatchNumber(OrderInfo orderInfo) {
        return null;
    }

    @Override
    public String getFreight(OrderInfo orderInfo) {
        return null;
    }

    @Override
    public String getSearchHint() {
        return "";
    }

    @Override
    public int getFeiOrderType() {
        return 0;
    }

}
